package 双指针;

public class Demo04 {
    /*
    * 双指针
    * */
    static class Solution {
        public int maxArea(int[] height) {
            int left = 0;
            int right = height.length-1;
            int sum = 0;
            while(left < right){
                int max = Math.min(height[left],height[right]);
                int temp = (right-left)*max;
                if(temp > sum){
                    sum = temp;
                }
                if(height[left] < height[right]){
                    left++;
                }else{
                    right--;
                }
            }
            return sum;
        }
    }
    /*
    * 暴力解法 不推荐
    * */
}
